﻿using System;
using BusinessObjects.Entities.Base;

namespace BusinessObjects.Entities
{
    public class AddressEntity : EntityBase<Guid>
    {
        public virtual string Address1 { get; set; }
        public virtual string Address2 { get; set; }
        public virtual string City { get; set; }
        public virtual string State { get; set; }
        public virtual string Zip { get; set; }

        public virtual bool Equals(AddressEntity other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return Equals(other.Address1, Address1) && Equals(other.Address2, Address2) && Equals(other.City, City) &&
                   other.Id.Equals(Id) && Equals(other.State, State) && Equals(other.Timestamp, Timestamp) &&
                   Equals(other.Zip, Zip);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != typeof(AddressEntity))
            {
                return false;
            }
            return Equals((AddressEntity)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = (Address1 != null ? Address1.GetHashCode() : 0);
                result = (result * 397) ^ (Address2 != null ? Address2.GetHashCode() : 0);
                result = (result * 397) ^ (City != null ? City.GetHashCode() : 0);
                result = (result * 397) ^ Id.GetHashCode();
                result = (result * 397) ^ (State != null ? State.GetHashCode() : 0);
                result = (result * 397) ^ (Timestamp != null ? Timestamp.GetHashCode() : 0);
                result = (result * 397) ^ (Zip != null ? Zip.GetHashCode() : 0);
                return result;
            }
        }

        public static bool operator ==(AddressEntity left, AddressEntity right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(AddressEntity left, AddressEntity right)
        {
            return !Equals(left, right);
        }
    }
}